package com.allwees.bs.module.oms.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.allwees.bs.core.model.order.entity.OrderModel;
import com.allwees.bs.module.core.wf.WorkflowAware;
import com.allwees.bs.module.oms.wf.EOmsOrderState;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;

/**
 * @see Order
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("oms_order")
public class OmsOrder extends OrderModel implements WorkflowAware {

    @JsonIgnore
    @JSONField(serialize = false)
    protected String wfName;

    @Column(length = 48)
    @JsonIgnore
    @JSONField(serialize = false)
    protected String wfUuid;

    @Column(length = 48)
    @JsonIgnore
    @JSONField(serialize = false)
    protected String wfState;

    /** 批次号 **/
    private String batchNo;

    @Override
    public String getBsKey() {
        return uuid;
    }

    public String getStateDesc() {
        if(StringUtils.isBlank(this.wfState)){
            return "";
        }
        EOmsOrderState state = EOmsOrderState.valueOf(this.wfState);
        return state != null ? state.getDesc() : "";
    }

}
